package com.googlecode.hypersphere.ws2ejb3.xml;

public class Field {

	private final String type;
	private final Link link;
	private final String name;
	private String tableName;
	private final boolean isPrimaryKey;

	public Field(String type, String name, Link link, boolean isPrimaryKey) {
		this.type = type;
		this.name = name;
		this.link = link;
		this.isPrimaryKey = isPrimaryKey;
	}

	public static Field createField(String string, String name, Link link, boolean isPrimaryKey) {
		String type = string.substring(string.indexOf("#") + 1, string
				.indexOf("-"));
		return new Field(type, name, link, isPrimaryKey);
	}

	public String getType() {
		return type;
	}

	public Link getLink() {
		return link;
	}

	public String getName() {
		return name;
	}

	public boolean isPrimaryKey() {
		return isPrimaryKey;
	}

	public String getTableName() {
		return tableName;
	}

	public void setTableName(String tableName) {
		this.tableName = tableName;
	}

}
